home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / progjrn / pj_7_6.arc / WINSTACK.C < prev    next >
C/C++ Source or Header  |  1988-04-25  |  821b  |  57 lines

  1. /*
  2.  * winstack.c    winPush(win) and winPop().
  3.  *
  4.  *        manage a stack of CURSES windows.
  5.  *
  6.  * (c) Copyright 1988 Aspen Scientific
  7.  * All Rights Reserved.
  8.  */
  9.  
  10. #include <curses.h>
  11. #include "winstack.h"    /* some defines */
  12.  
  13. /* the stack
  14.  */
  15. static WINDOW *ws[ WIN_MAX ];
  16.  
  17. static int ws_idx = 0;
  18.  
  19. int
  20. winPush( win )
  21. WINDOW *win;
  22. {
  23.     /** stack overflow?
  24.      **/
  25.     if (ws_idx == WIN_MAX)
  26.         return (0);        /** error **/
  27.  
  28.     touchwin( win );
  29.     wrefresh( win );
  30.  
  31.     ws[ ws_idx++ ] = win;
  32.  
  33.     return (1);            /** good **/
  34. }
  35.  
  36. void
  37. winPop()
  38. {
  39.     register int i;
  40.  
  41.     /** stack underflow?
  42.      **/
  43.     if (ws_idx == 0)
  44.         return;
  45.  
  46.     ws[ --ws_idx ] = (WINDOW *)0;
  47.  
  48.     i=0;
  49.     while (i < ws_idx) {
  50.         touchwin(ws[i]);
  51.         wnoutrefresh(ws[i]);    /* to virtual screen */
  52.         ++i;
  53.     }
  54.  
  55.     doupdate();    /* to physical screen */
  56. }
  57.